//2639.查询网格图中每一列的宽度
//https://leetcode.cn/problems/find-the-width-of-columns-of-a-grid
class Solution {
public:
    vector<int> findColumnWidth(vector<vector<int>>& grid) {
        int m = grid.size(), n = grid[0].size();
        vector<int> ret;
        ret.reserve(n);
        for (int i = 0; i < n; ++i)
        {
            int maxn = INT_MIN;
            int minn = INT_MAX;
            for (int k = 0; k < m; ++k)
            {
                maxn = max(maxn, grid[k][i]);
                minn = min(minn, grid[k][i]);
            }
            ret.push_back(max(to_string(maxn).size(), to_string(minn).size()));
        }
        return ret;
    }
};